// components/index/second-activity/second-activity.js
Component({
  /**
   * 组件的属性列表
   */
  properties: {
    current: {
      type: Object,
      default: ()=>({})
    },
    type: {
      type: String,
      default: "limit"
    },
    activityId:{
      type:Number,
      default:1
    }
  },

  /**
   * 组件的初始数据
   */
  data: {
    titleList:{
      "limit": "http://booking-prod.oss-cn-shenzhen.aliyuncs.com/tata/index/limit.png",
      "baokuai": "http://booking-prod.oss-cn-shenzhen.aliyuncs.com/tata/index/baokuai.png",
      "hot": "http://booking-prod.oss-cn-shenzhen.aliyuncs.com/tata/index/hot.png"
    },
    goodList:[
      {
        id:12,
        imageUrl:"https://source.unsplash.com/750x200?fruit,3",
        title:"标题",
        price:123,
        originPrice:0,
        num:123
      },
      {
        id:13,
        imageUrl:"https://source.unsplash.com/750x200?fruit,3",
        title:"标题",
        price:123,
        originPrice:0,
        num:1
      },
      {
        id:14,
        imageUrl:"https://source.unsplash.com/750x200?fruit,3",
        title:"标题",
        price:123,
        originPrice:0,
        num:0
      }
    ]
  },

  /**
   * 组件的方法列表
   */
  methods: {
    addCart(e){
      const {id, index} = e.currentTarget.dataset;
      // this.triggerEvent("add", this.data.item.commodityId, 1, "add");
      this.triggerEvent("add", {
        id: id,
        update: 1,
        type: this.data.type,
        index: index
      });
    },
    minusCart(e){
      const {id, index} = e.currentTarget.dataset;
      // this.triggerEvent("minus", this.data.item.commodityId, -1, "minus");
      this.triggerEvent("minus", {
        id: id,
        update: -1,
        type: this.data.type,
        index: index
      });
    },
    goTo(e){
      const id = e.currentTarget.dataset.id;
      wx.navigateTo({
        url:"/pages/goods/goods?id="+id,
      })
    },
  }
})
